#include<stdio.h>
#include<stdlib.h>

#define true 1
#define false 0
#define ElementType void*

struct stack
{
    ElementType *stack;
    int len;
    int size;
};

int StackInit(struct stack *array)
{
    array->stack = (struct stack*)malloc(sizeof(struct stack));
    if(array->stack==NULL)
    {
        printf("malloc error!\n");
        return false;
    }
    return true;
}


int ReallocArray(struct stack *array)
{
    ElementType *temp = array->stack;
    array->size = array->size*2;
    array->stack = (struct stack*)malloc(sizeof(struct stack));
    if(array->stack==NULL)
    {
        printf("malloc error!\n");
        array->stack = temp;
        array->size = array->size/2;
        return false;        
    }
    for(int i=0;i<array->len;i++)
    {
        array->stack[i] = temp[i];
    }
    free(temp);
    temp = NULL;
    return true;
} 

void push(struct stack *array,ElementType element)
{
    if(array->len>=array->size)
    {
        if(ReallocArray(array)==false)
        {
            printf("can not contain more element!\n");
            return;
        }        
    }
    
}